import 'package:app/common_widget/colors.dart';
import 'package:app/home_module/home_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'mine_module/mine_page.dart';

class Tabs extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return TabState();
  }
}

class TabState extends State<Tabs>{
  int _currentIndex = 0;
  List _listPageData = [ //页面集合
    HomePage(),
    HomePage(),
    Container(),
    HomePage(),
    MinePage(),
    // HomePages(),
    // AddPage(),
    // SettingPage()
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _listPageData[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this._currentIndex==2?1:this._currentIndex,//配置对应的索引值选中
        onTap: (int index){//index 表示选择选项
          setState(() {
            if(index==2){
              return;
            }
            this._currentIndex = index;//改变页面
          });
        },
        iconSize: 20.0,//icon的大小
        fixedColor: AppColor.themeColor,//选中颜色
        selectedFontSize: 12,
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(
              icon: Icon(Icons.home,),
              label: '消息'
          ),
          BottomNavigationBarItem(
              icon: Image.asset('images/xiezuo_icon.png',width: 25,height: 25,),
              activeIcon: Image.asset('images/xiezuo_icon.png',width: 25,height: 25,color: AppColor.themeColor,),
              label: '协作',
          ),
          BottomNavigationBarItem(
            // icon: Image.asset('images/xiezuo_icon.png',width: 25,height: 25,),
            // activeIcon: Image.asset('images/xiezuo_icon.png',width: 25,height: 25,color: AppColor.themeColor,),
            label: '',
            icon: Container(),
          ),
          BottomNavigationBarItem(
              icon: Image.asset('images/tongxunlu_icon.png',width: 25,height: 25,),
              activeIcon: Image.asset('images/tongxunlu_icon.png',width: 25,height: 25,color: AppColor.themeColor,),

              label: '通讯录'
          ),

          // BottomNavigationBarItem(
          //     icon: Icon(Icons.add),
          //     label: 'Text("添加")'
          // ),
          BottomNavigationBarItem(
              activeIcon: Image.asset('images/my_icon.png',width: 25,height: 25,color: AppColor.themeColor,),
              icon: Image.asset('images/my_icon.png',width: 25,height: 25,),
              label: '我的'
          ),
        ],
      ),
      floatingActionButton: Container(//Container框
          height: 45,
          width: 45,
          decoration: BoxDecoration(//实现圆
            borderRadius: BorderRadius.circular(40),
            color: Colors.white,
          ),
          margin: EdgeInsets.only(top: 25),
          child: Image.asset('images/bottom_log_icon.png',fit: BoxFit.contain,),
          // margin: EdgeInsets.only(top:30,left: 15,right: 15),//外部margin
          // padding: EdgeInsets.all(18), //内部margin
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,//Floating放在底部中间
    );
  }
}